//============================================================================
// Name        : strator.cpp
// Author      : norix
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#define WIN_WIDTH 800
#define WIN_HEIGHT 600

#include "main.h"

int main(int argc, char** args) {

	// TEST MOAR

	// asdasd

	cEngine engine;

	engine.Graphics->Initialize(WIN_WIDTH, WIN_HEIGHT, 32, "TestMe", "Approve.bmp");
	engine.Graphics->MakeWindow();

//	SDL_Delay(1000);
//	engine.Graphics->ResizeWindow(640,480);

	cFont* font1 = new cFont("Spy Lord.ttf", 24);
	font1->SetForeColor({255,0,0});
	font1->SetBackColor({255,255,255});

	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	bool run = true;
	while (run)
	{
		engine.Input->Update();
		if (engine.Input->IsKeyDown(KEY_ESCAPE))
			run = false;

		if (engine.Input->IsKeyHeld(KEY_LEFT))
		{
			engine.Camera->Move(-1.0f, 0.0f);
		}
		if (engine.Input->IsKeyHeld(KEY_RIGHT))
		{
			engine.Camera->Move(1.0f, 0.0f);
		}
		if (engine.Input->IsKeyHeld(KEY_UP))
		{
			engine.Camera->Move(0.0f, -1.0f);
		}
		if (engine.Input->IsKeyHeld(KEY_DOWN))
		{
			engine.Camera->Move(0.0f, 1.0f);
		}

		glClear(GL_COLOR_BUFFER_BIT);
		glColor3f(1.0f, 0.5f, 0.5f);

		engine.Graphics->DrawRectangle(10, 10, 100, 100);
		engine.Graphics->DrawRectangle(10, 150, 100, 250);

		engine.Graphics->DrawRectangle(150, 10, 250, 100);

		engine.Graphics->DrawRectangle(150, 150, 250, 250);

		font1->Draw("Hi =(", 100, 100);

		engine.Graphics->SwapBuffer();
	}
	return 0;
}

//void testStateManager()
//{
//	printf("*** TEST StateManager ***");
//	cStateManager* manState = new cStateManager();
//
//	manState->Process(NULL);
//	manState->Push(func1, NULL);
//	manState->Push(func2, NULL);
//	manState->Process(NULL);
//	manState->Pop(NULL);
//	manState->Process(NULL);
//
//	delete manState;
//}
//
//int pid1, pid2, pid3;
//void testProcessManager()
//{
//	printf("\n*** TEST ProcessManager ***\n");
//
//	cProcessManager* manProcess = new cProcessManager();
//	manProcess->debug = true;
//	manProcess->Process(NULL);
//	pid1 = manProcess->Push(func1, NULL);
//	pid2 = manProcess->Push(func2, NULL);
//	pid3 = manProcess->Push(func3, NULL);
//	manProcess->Process(NULL); // frame pid3
//	manProcess->Pop(pid3);
//	manProcess->Process(NULL); // frame pid2
//	manProcess->Pop(pid2);
//	manProcess->Process(NULL); // frame pid1
//
//	printf("\n*** TEST 2 ProcessManager ***\n");
//	manProcess->PopAll(NULL);
//	manProcess->Process(NULL);
//	pid1 = manProcess->Push(func1, NULL);
//	pid2 = manProcess->Push(func2, NULL);
//	pid3 = manProcess->Push(func3, NULL);
//	manProcess->Process(NULL); // frame pid3
//	manProcess->Pop(pid3);
//	manProcess->Process(NULL); // frame pid2
//	manProcess->Pop(pid2);
//	manProcess->Process(NULL); // frame pid1
//
//	delete manProcess;
//}

//void func1(void* CallerPtr, Purpose purp)
//{
//	char name[] = "func1";
//
//	switch(purp)
//	{
//	case INIT_PURPOSE:
//		printf("%s INIT\n", name);
//		break;
//	case STOP_PURPOSE:
//		printf("%s STOP\n", name);
//		break;
//	case FRAME_PURPOSE:
//		printf("%s FRAME\n", name);
//		break;
//	case NO_PURPOSE:
//		printf("%s NO PURPOSE\n", name);
//		break;
//	}
//}
//
//void func2(void* CallerPtr, Purpose purp)
//{
//	char name[] = "func2";
//
//	switch(purp)
//	{
//	case INIT_PURPOSE:
//		printf("%s INIT\n", name);
//		break;
//	case STOP_PURPOSE:
//		printf("%s STOP\n", name);
//		break;
//	case FRAME_PURPOSE:
//		printf("%s FRAME\n", name);
//		break;
//	case NO_PURPOSE:
//		printf("%s NO PURPOSE\n", name);
//		break;
//	}
//}
//
//void func3(void* CallerPtr, Purpose purp)
//{
//	char name[] = "func3";
//
//	switch(purp)
//	{
//	case INIT_PURPOSE:
//		printf("%s INIT\n", name);
//		break;
//	case STOP_PURPOSE:
//		printf("%s STOP\n", name);
//		break;
//	case FRAME_PURPOSE:
//		printf("%s FRAME\n", name);
//		break;
//	case NO_PURPOSE:
//		printf("%s NO PURPOSE\n", name);
//		break;
//	}
//}
